package com.pay.ioopos.activity;

import android.content.Intent;
import android.os.Bundle;

import com.pay.ioopos.KeyInfo;
import com.pay.ioopos.R;
import com.pay.ioopos.fragment.StatisticsMenuFragment;
import com.pay.ioopos.fragment.StatisticsOverviewFragment;
import com.pay.ioopos.fragment.StatisticsPayListFragment;
import com.pay.ioopos.fragment.StatisticsRefundListFragment;
import com.pay.ioopos.fragment.TipVerticalFragment;

import static com.pay.ioopos.KeyInfo.KEY_CANCEL;
import static com.pay.ioopos.KeyInfo.KEY_ENTER;
import static com.pay.ioopos.KeyInfo.KEY_NUM_1;
import static com.pay.ioopos.KeyInfo.KEY_NUM_2;
import static com.pay.ioopos.KeyInfo.KEY_NUM_3;
import static com.pay.ioopos.KeyInfo.KEY_NUM_4;

public class StatisticsActivity extends AbstractActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_statistics);
        setMainFragment(new StatisticsMenuFragment());
    }

    @Override
    public boolean onKeyDown(KeyInfo keyInfo) {
        if (mainFragment instanceof StatisticsMenuFragment) {
            if (keyInfo == KEY_ENTER || keyInfo == KEY_CANCEL) {
                startActivity(new Intent(this, MainActivity.class));
            } else if (keyInfo == KEY_NUM_1) {
                setMainFragment(new StatisticsOverviewFragment());
            } else if (keyInfo == KEY_NUM_2) {
                setMainFragment(new StatisticsPayListFragment());
            } else if (keyInfo == KEY_NUM_3) {
                setMainFragment(new StatisticsRefundListFragment());
            } else if (keyInfo == KEY_NUM_4) {
                startActivity(new Intent(this, RefundActivity.class));
            }
        } else if (mainFragment instanceof StatisticsOverviewFragment) {
            if (keyInfo == KEY_ENTER || keyInfo == KEY_CANCEL) {
                setMainFragment(new StatisticsMenuFragment());
            }
        } else if (mainFragment instanceof TipVerticalFragment) {
            if (keyInfo == KEY_ENTER || keyInfo == KEY_CANCEL) {
                setMainFragment(new StatisticsMenuFragment());
            }
        }
        return false;
    }

}
